package ru.spbu.math.android.cbrf.dataprovider.web;

import java.util.ArrayList;
import java.util.List;


/**
 * Class for keeping urls for CBRF
 * @author  Svetlana Zemlyanskaya
 */

public class CbrfUrlIdStore {
    /**
	 * @uml.property  name="instance"
	 * @uml.associationEnd  
	 */
    private static CbrfUrlIdStore instance = new CbrfUrlIdStore();
    private static List<CbrfUrlId> CbrfUrlIdList;


    /**
     * Get DataBaseUrlId List from DataBaseUrlIdStore
     *
     * @return List<StockItem>
     */
    public List<CbrfUrlId> getDataBaseUrlIdList() {
        return CbrfUrlIdList;
    }


    protected CbrfUrlIdStore() {
        CbrfUrlIdList = new ArrayList<CbrfUrlId>();
        CbrfUrlId item = new CbrfUrlId("RUB", "");
        CbrfUrlIdList.add(item);
        item = new CbrfUrlId("GBP", "R01035");
        CbrfUrlIdList.add(item);
        item = new CbrfUrlId("BYR", "R01090");
        CbrfUrlIdList.add(item);
        item = new CbrfUrlId("EUR", "R01239");
        CbrfUrlIdList.add(item);
        item = new CbrfUrlId("USD", "R01235");
        CbrfUrlIdList.add(item);
        item = new CbrfUrlId("AUD", "R01010");
        CbrfUrlIdList.add(item);
        item = new CbrfUrlId("DKK", "R01215");
        CbrfUrlIdList.add(item);
        item = new CbrfUrlId("ISK", "R01310");
        CbrfUrlIdList.add(item);
        item = new CbrfUrlId("KZT", "R01335");
        CbrfUrlIdList.add(item);
        item = new CbrfUrlId("CAD", "R01350");
        CbrfUrlIdList.add(item);
        item = new CbrfUrlId("CNY", "R01375");
        CbrfUrlIdList.add(item);
        item = new CbrfUrlId("NOK", "R01535");
        CbrfUrlIdList.add(item);
        item = new CbrfUrlId("XDR", "R01589");
        CbrfUrlIdList.add(item);
        item = new CbrfUrlId("SGD", "R01625");
        CbrfUrlIdList.add(item);
        item = new CbrfUrlId("TRY", "R01700J");
        CbrfUrlIdList.add(item);
        item = new CbrfUrlId("UAH", "R01720");
        CbrfUrlIdList.add(item);
        item = new CbrfUrlId("SEK", "R01770");
        CbrfUrlIdList.add(item);
        item = new CbrfUrlId("CHF", "R01775");
        CbrfUrlIdList.add(item);
        item = new CbrfUrlId("JPY", "R01820");
        CbrfUrlIdList.add(item);
    }

    /**
     * Get DataBaseUrlIdStore
     *
     * @return DataBaseUrlIdStore
     */
    public static CbrfUrlIdStore Instance() {
        return instance;
    }

    /**
     * Get DataBaseUrlId from DataBaseUrlIdStore by dataBaseId
     *
     * @param id
     * @return DataBaseUrlId
     */
    public CbrfUrlId findByDataBaseCode(String id) {
        for (CbrfUrlId item : CbrfUrlIdList) {
            if (item.getDataBaseCode().equals(id)) {
                return item;
            }
        }
        return null;
    }

    /**
     * Get DataBaseUrlId from DataBaseUrlIdStore by urlId
     *
     * @param id
     * @return DataBaseUrlId
     */
    public CbrfUrlId findByUrlId(String id) {
        for (CbrfUrlId item : CbrfUrlIdList) {
            if (item.getUrlId().equals(id)) {
                return item;
            }
        }
        return null;
    }
}

